﻿using System.Collections.Specialized;
using System.IO;
using System.Web;

/// <summary>
/// Defines all requests made to this application.
/// </summary>
public struct RequestBag
{
    /// <summary>
    /// Default constructor.
    /// </summary>
    /// <param name="Context">
    /// The <see cref="System.Web.HttpContext"/>.
    /// </param>
    public RequestBag(HttpContext Context)
    {
        this.Context = Context;
        NameValueCollection qs = Context.Request.QueryString;

        this.Command = qs["cmd"];
        this.DataConnectionId = qs["cnn"];
        this.DataId = qs["id"];

        Context.Request.InputStream.Position = 0;
        StreamReader reader = new StreamReader(Context.Request.InputStream);
        this.XmlPostData = reader.ReadToEnd();
    }

    /// <summary>
    /// <see cref="DataCommand"/>
    /// </summary>
    public string Command;

    /// <summary>
    /// The <see cref="System.Web.HttpContext"/>
    /// </summary>
    public HttpContext Context;

    /// <summary>
    /// Data connection identifer.
    /// </summary>
    public string DataConnectionId;

    /// <summary>
    /// Data item identifer.
    /// </summary>
    public string DataId;

    /// <summary>
    /// XML post data.
    /// </summary>
    public string XmlPostData;
}
